// // src/views/data/hourData.ts

// const SZHourData = {
//     priceinfo: [
//         {
//             price: 3000,
//             increase: 10,
//             volume: 1500,
//             ratio: 0.33,
//             amount: 500000,
//             datetime: "2023-10-01 09:00"
//         },
//         {
//             price: 3010,
//             increase: 5,
//             volume: 1600,
//             ratio: 0.16,
//             amount: 510000,
//             datetime: "2023-10-01 10:00"
//         },
//         {
//             price: 3015,
//             increase: -5,
//             volume: 1400,
//             ratio: -0.16,
//             amount: 480000,
//             datetime: "2023-10-01 11:00"
//         },
//         // ... 其他数据 ...
//     ]
// };

// {"time":"1678411800","price":"3255.51","ratio":"-0.63%","increase":"-20.58","volume":"2925368","avgPrice":"3261.35","amount":"29.00\u4ebf","timeKey":"0930","datetime":"03-10 09:30","oriAmount":"2900320446","show":"1"}





// 用于生成指定格式时间字符串的函数，时间间隔为一分钟
function generateTimeString(startTime, index) {
    const date = new Date(startTime);
    date.setMinutes(date.getMinutes() + index);
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0');
    const day = String(date.getDate()).padStart(2, '0');
    const hour = String(date.getHours()).padStart(2, '0');
    const minute = String(date.getMinutes()).padStart(2, '0');
    return `${year}-${month}-${day} ${hour}:${minute}`;
}

// 生成模拟数据的函数，排除11:30 - 13:00时间段的数据
function generateData() {
    const startTime = new Date('2023-10-01 09:00:00');
    const data = [];
    const price = 3000;
    const baseVolume = 1500;
    const baseAmount = 500000;
    for (let i = 0; i < 300; i++) {
        const currentTime = generateTimeString(startTime, i);
        const hour = parseInt(currentTime.split(' ')[1].split(':')[0], 10);
        const minute = parseInt(currentTime.split(' ')[1].split(':')[1], 10);
        // 判断是否处于11:30 - 13:00这个时间段，如果是则跳过本次循环，不生成这条数据
        if ((hour === 11 && minute >= 30) || (hour === 12 && hour < 13)) {
            continue;
        }
        const randomIncrease = Math.floor(Math.random() * 20 - 10);  // 价格涨跌在-10到10之间随机
        const randomVolume = Math.floor(Math.random() * 300 + baseVolume - 150);  // 成交量在一定范围内随机波动
        const randomAmount = Math.floor(Math.random() * 50000 + baseAmount - 25000);  // 成交额在一定范围内随机波动
        const ratio = (randomIncrease / price).toFixed(2);  // 计算涨跌比例并保留两位小数
        data.push({
            price: price + randomIncrease,
            increase: randomIncrease,
            volume: randomVolume,
            ratio: ratio,
            amount: randomAmount,
            datetime: currentTime
        });
    }
    return data;
}

const SZHourData = {
    priceinfo: generateData()
};

// console.log(SZHourData);
export default SZHourData;